﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using StudentManage.Data;

namespace StudentManage.Web.Personal
{
    public partial class MyInfo : SecurityPage
    {
        private void LoadData()
        {
            UserList md = (UserList)Session["UserMD"];
            this.txt_UName.Text = md.UName;
            this.txt_Tel.Text = md.Tel;
            this.txt_Specialty.Text = md.Specialty;
            this.txt_Hobby.Text = md.Hobby;
            this.txt_Experience.Text = md.Experience;

            if (Convert.ToBoolean(md.IsStudent))
            {
                xy_xsxx info = xy_xsxx.Where("XH=@0",md.XH).First();
                this.lab_XY.Text = info.XY;
                this.lab_XZB.Text = info.XZB;
                this.lab_ZYMC.Text = info.ZYMC;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack) return;
            this.LoadData();
        }

        protected void Btn_Save_Click(object sender, EventArgs e)
        {
            UserList md = (UserList)Session["UserMD"];
            md.UName = this.txt_UName.Text.Trim();
            md.Tel = this.txt_Tel.Text.Trim();
            md.Specialty = this.txt_Specialty.Text.Trim();
            md.Hobby = this.txt_Hobby.Text.Trim();
            md.Experience = this.txt_Experience.Text.Trim();
            UserList.Update(md, "id=@0", md.id);
            Session["UserMD"] = md;
            ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script>alert('保存成功！');</script>");
        }
    }
}